package com.sline.Singleton;

public class Demo1_Singleton {
    public static void main(String[] args) {

    }
}

/*单例*/
//class Singleton {
//    private Singleton() {}
//
//    private static Singleton s = new Singleton();
//    public static Singleton getInstance() {
//        return s;
//    }
//}

/*单例的延迟加载*/
//class Singleton {
//    private Singleton() {}
//
//    private static Singleton s;
//    public static Singleton getInstance() {
//        if (s == null) {
//            s = new Singleton();
//        }
//        return s;
//    }
//}

class Singleton {
    private Singleton() {}

    public static final Singleton s = new Singleton();
}
